//
//  WmcCancellationValidationVM.swift
//  YPWatermarkCamera
//
//  Created by 马涛 on 2022/6/23.
//

import Foundation
import RxRelay
import RxSwift
import YPBedrock

class WmcCancellationValidationVM: WmcCancellationFeedbackVM {
        
    let codeResult: BehaviorRelay<WmcCodeMsgRespModel?> = .init(value: nil)
    
    /// 发送验证码
    /// - Returns: description
    func sendCode() -> Void {
        WmcNetwork.request(.general(method: .post, path: "/message/home/telCode", params: ["tel": self.tel])).mapModel(WmcCodeMsgRespModel.self, throwErrorEnable: false, customThrowError: nil).subscribe {[weak self] res in
            WmcLogManager.Log("验证码= ======== \(res)")
            guard let weakSelf = self else { return }
            weakSelf.codeResult.accept(res)
        } onError: { error in
            WmcHudManager.toast(error)
        }.disposed(by: rx.disposeBag)
    }
}
 
